package com.itany.corejava.day10;

import java.util.Arrays;
import java.util.Comparator;

public class Test1 {

    public static void main(String[] args) {
        Circle c1=new Circle(6);
        Circle c2=new Circle(2);

        Rectangle r1=new Rectangle(5,2);
        Rectangle r2=new Rectangle(4,3);

        Triangle t1=new Triangle(7,4);
        Triangle t2=new Triangle(3,6);

        Graphics[] graphics={c1,c2,r1,r2,t1,t2};

        Arrays.sort(graphics);

        for (int i = 0; i < graphics.length; i++) {
            System.out.println(graphics[i]);
        }
        System.out.println("--------------------------");

//        Arrays.sort(graphics,(o1,o2)->new Double(o2.area()).compareTo(o1.area()));


        Arrays.sort(graphics, new Comparator<Graphics>() {
            @Override
            public int compare(Graphics o1, Graphics o2) {
                return new Double(o2.area()).compareTo(o1.area());
            }
        });

        for (int i = 0; i < graphics.length; i++) {
            System.out.println(graphics[i]);
        }





    }


}
